package com.pingan.haofang.searchcloud.common.constants;

import com.pingan.haofang.framework.common.functional.lang.control.base.annotation.Value;

/**
 * 是否启用查询优化
 *
 * @author SONGBANGYONG396
 * @date 2018/7/2
 * @since 1.0.0
 */
public enum QueryOptimizeEnum {

    ENABLE(1, "启用"), DISABLE(0, "禁用");

    public final Integer code;

    private final String desc;

    QueryOptimizeEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Value
    public Integer code() {
        return code;
    }

    /**
     * 根据编码获取枚举
     * @param code
     * @return
     */
    public static QueryOptimizeEnum of(Integer code) {
        for (QueryOptimizeEnum qo : QueryOptimizeEnum.values()) {
            if (qo.code == code) {
                return qo;
            }
        }
        return DISABLE;
    }

}
